package com.apop.demo.encrypt;

public enum EncryptTypeEnum {

    NONE("none", "不加密"),
    FZSM("fzsm", "FZSM加密算法"),
    RSA("rsa", "RSA加密算法"),
    ;

    private final String type;
    private final String describe;

    EncryptTypeEnum(String type, String describe) {
        this.type = type;
        this.describe = describe;
    }

    public String getType() {
        return type;
    }

    public String getDescribe() {
        return describe;
    }

    /**
     * 根据类型字符串查找对应的枚举值
     *
     * @param type 类型字符串
     * @return 对应的枚举值，如果未找到则返回null
     */
    public static EncryptTypeEnum fromType(String type) {
        for (EncryptTypeEnum value : values()) {
            if (value.getType().equalsIgnoreCase(type)) {
                return value;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return String.format("EncryptTypeEnum{type='%s', describe='%s'}", type, describe);
    }

}
